<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="日期" prop="complaintDate">
        <el-input
          v-model="queryParams.complaintDate"
          placeholder="请输入日期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="受理号码" prop="acceptanceNumber">
        <el-input
          v-model="queryParams.acceptanceNumber"
          placeholder="请输入受理号码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="投诉区县" prop="complaintDistrict">
        <el-input
          v-model="queryParams.complaintDistrict"
          placeholder="请输入投诉区县"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:complaint:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:complaint:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:complaint:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-upload
          class="upload-demo"
          :headers="headers"
          :action="uploadUrl"
          :on-success="handleSuccess"
          :show-file-list="false"
          name="file"
          ref="upload"
          multiple>
          <el-button
            type="success"
            plain
            icon="el-icon-upload2"
            size="mini"
            v-hasPermi="['system:complaint:import']"
          >导入
          </el-button>
        </el-upload>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:complaint:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table stripe v-loading="loading" :data="complaintList" height="650" @selection-change="handleSelectionChange">
      <el-table-column type="index" width="55" align="center"/>
      <el-table-column min-width="150px" label="日期" align="center" prop="complaintDate"/>
      <el-table-column min-width="200px" label="受理号码" align="center" prop="acceptanceNumber"/>
      <el-table-column min-width="200px" label="投诉唯一标识" align="center" prop="complaintUniqueIdentifier"/>
      <el-table-column min-width="100px" label="重复投诉次数" align="center" prop="numberOfRepeatedComplaints"/>
      <el-table-column min-width="250px" label="工单流水号" align="center" prop="workOrderSerialNumber"/>
      <el-table-column min-width="100px" label="回访人员" align="center" prop="returningVisitor"/>
      <el-table-column min-width="100px" label="投诉类型" align="center" prop="typeOfComplaint"/>
      <el-table-column min-width="150px" label="归一化地址" align="center" prop="normalizedAddress"/>
      <el-table-column min-width="150px" label="归一化地址(TOP统计)" align="center" prop="normalizedAddressStatistics"/>
      <el-table-column min-width="100px" label="优先级" align="center" prop="priority"/>
      <el-table-column min-width="100px" label="投诉区县" align="center" prop="complaintDistrict"/>
      <el-table-column min-width="200px" label="投诉详细地址" align="center" prop="complaintAddress"
                       show-overflow-tooltip="show-overflow-tooltip"/>
      <el-table-column min-width="200px" label="问题描述" align="center" prop="problemDescription"
                       show-overflow-tooltip="show-overflow-tooltip"/>
      <el-table-column min-width="100px" label="问题定界" align="center" prop="problemDelimiting"/>
      <el-table-column min-width="150px" label="问题分类" align="center" prop="problemClassification"/>
      <el-table-column min-width="100px" label="业务分类" align="center" prop="serviceClassification"/>
      <el-table-column min-width="100px" label="投诉网络制式" align="center" prop="complaintNetworkSystem"/>
      <el-table-column min-width="100px" label="覆盖场景" align="center" prop="overlayScene"/>
      <el-table-column min-width="200px" label="当前进展" align="center" prop="currentProgress"
                       show-overflow-tooltip="show-overflow-tooltip"/>
      <el-table-column min-width="200px" label="当前环节" align="center" prop="currentLink"/>
      <el-table-column min-width="100px" label="解决方案大类" align="center" prop="solutionCategory"/>
      <el-table-column min-width="150px" label="解决方案小类" align="center" prop="solutionSubclass"/>
      <el-table-column min-width="100px" label="是否存在工期" align="center" prop="existenceDuration"/>
      <el-table-column min-width="100px" label="存在工期名称" align="center" prop="existenceDurationName"/>
      <el-table-column min-width="150px" label="具体方案" align="center" prop="specificScheme"/>
      <el-table-column min-width="150px" label="经度" align="center" prop="longitude"/>
      <el-table-column min-width="150px" label="纬度" align="center" prop="latitude"/>
      <el-table-column min-width="150px" label="方案处理进展" align="center" prop="projectProcessingProgress"/>
      <el-table-column min-width="150px" label="方案是否落地" align="center" prop="planImplementation"/>
      <el-table-column min-width="150px" label="用户10分评价意愿" align="center" prop="userEvaluationIntention"/>
      <el-table-column min-width="150px" label="是否上传闭环录音" align="center" prop="uploadClosedLoopRecording"/>
      <el-table-column min-width="150px" label="投诉安抚责任人" align="center"
                       prop="complaintsAppeaseThoseResponsible"/>
      <el-table-column min-width="150px" label="投诉处理组" align="center" prop="complaintsHandlingUnit"/>
      <el-table-column min-width="150px" label="投诉工单派发日期" align="center" prop="dateOfComplaint"/>
      <el-table-column min-width="150px" label="处理责任人更新反馈时间" align="center" prop="updateFeedbackTime"/>
      <el-table-column min-width="150px" label="用户闭环时间" align="center" prop="closedLoopTime"/>
      <el-table-column min-width="150px" label="投诉处理备注" align="center" prop="complaintHandlingRemarks"/>
      <el-table-column min-width="150px" label="投诉是否反馈更新" align="center" prop="complaintFeedbackUpdate"/>
      <el-table-column min-width="150px" label="自投诉起时长" align="center" prop="timeSinceTheComplaint"/>
      <el-table-column min-width="150px" label="是否超时工单标记" align="center" prop="overtimeWorkOrderFlag"/>
      <el-table-column min-width="100px" label="处理时间" align="center" prop="processingTime"/>
      <el-table-column min-width="100px" label="工单状态" align="center" prop="workOrderStatus"/>
      <el-table-column min-width="200px" label="操作" align="center" class-name="small-padding fixed-width"
                       width="120px" fixed="right">
        <template slot-scope="scope">
<!--          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:complaint:edit']"
          >修改
          </el-button>-->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:complaint:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改投诉问题对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="180px">
        <el-row>
          <el-col span="8">
            <el-form-item label="日期" prop="complaintDate">
              <el-input v-model="form.complaintDate" placeholder="请输入日期"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="受理号码" prop="acceptanceNumber">
              <el-input v-model="form.acceptanceNumber" placeholder="请输入受理号码"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="投诉唯一标识" prop="complaintUniqueIdentifier">
              <el-input v-model="form.complaintUniqueIdentifier" placeholder="请输入投诉唯一标识"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="重复投诉次数" prop="numberOfRepeatedComplaints">
              <el-input v-model="form.numberOfRepeatedComplaints" placeholder="请输入重复投诉次数"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="工单流水号" prop="workOrderSerialNumber">
              <el-input v-model="form.workOrderSerialNumber" placeholder="请输入工单流水号"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="回访人员" prop="returningVisitor">
              <el-input v-model="form.returningVisitor" placeholder="请输入回访人员"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="投诉类型" prop="typeOfComplaint">
              <el-select v-model="form.typeOfComplaint" placeholder="请选择投诉类型">
                <el-option v-for="dict in dict.type.type_of_complaint"
                           :key="dict.value"
                           :label="dict.label"
                           :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="归一化地址" prop="normalizedAddress">
              <el-input v-model="form.normalizedAddress" placeholder="请输入归一化地址"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="归一化地址(TOP统计)" prop="normalizedAddressStatistics">
              <el-input v-model="form.normalizedAddressStatistics" placeholder="请输入归一化地址(TOP统计)"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="优先级" prop="priority">
              <el-input v-model="form.priority" placeholder="请输入优先级"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="投诉区县" prop="complaintDistrict">
              <el-select v-model="form.complaintDistrict" placeholder="请选择投诉区县">
                <el-option v-for="dict in dict.type.complaint_district"
                           :key="dict.value"
                           :label="dict.label"
                           :value="dict.label"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="投诉详细地址" prop="complaintAddress">
              <el-input v-model="form.complaintAddress" placeholder="请输入投诉详细地址"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="问题描述" prop="problemDescription">
              <el-input v-model="form.problemDescription" placeholder="请输入问题描述"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="问题定界" prop="problemDelimiting">
              <el-select v-model="form.problemDelimiting" placeholder="请选择问题定界">
                <el-option v-for="dict in dict.type.problem_delimiting"
                           :key="dict.value"
                           :label="dict.label"
                           :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="问题分类" prop="problemClassification">
              <el-select v-model="form.problemClassification" placeholder="请选择问题分类"">
              <el-option v-for="dict in dict.type.problem_classification"
                         :key="dict.value"
                         :label="dict.label"
                         :value="dict.value"
              ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="业务分类" prop="serviceClassification">
              <el-input v-model="form.serviceClassification" placeholder="请输入业务分类"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="投诉网络制式" prop="complaintNetworkSystem">
              <el-select v-model="form.complaintNetworkSystem" placeholder="请选择投诉网络制式">
                <el-option v-for="dict in dict.type.complaint_network_system"
                           :key="dict.value"
                           :label="dict.label"
                           :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="覆盖场景" prop="overlayScene">
              <el-select v-model="form.overlayScene" placeholder="请选择覆盖场景">
                <el-option v-for="dict in dict.type.overlay_scene"
                           :key="dict.value"
                           :label="dict.label"
                           :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="当前进展" prop="currentProgress">
              <el-input v-model="form.currentProgress" placeholder="请输入当前进展"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="当前环节" prop="currentLink">
              <el-select v-model="form.currentLink" placeholder="请选择当前环节">
                <el-option v-for="dict in dict.type.work_order_link"
                           :key="dict.value"
                           :label="dict.label"
                           :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="解决方案大类" prop="solutionCategory">
              <el-select v-model="form.solutionCategory" placeholder="请选择解决方案大类">
                <el-option v-for="dict in dict.type.solution_category"
                           :key="dict.value"
                           :label="dict.label"
                           :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="解决方案小类" prop="solutionSubclass">
              <el-select v-model="form.solutionSubclass" placeholder="请选择解决方案小类">
                <el-option v-for="dict in dict.type.solution_subclass"
                           :key="dict.value"
                           :label="dict.label"
                           :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否存在工期" prop="existenceDuration">
              <el-input v-model="form.existenceDuration" placeholder="请输入是否存在工期"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="存在工期名称" prop="existenceDurationName">
              <el-select v-model="form.existenceDurationName" placeholder="请选择存在工期名称">
                <el-option v-for="dict in dict.type.duration_name"
                           :key="dict.value"
                           :label="dict.label"
                           :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="具体方案" prop="specificScheme">
              <el-input v-model="form.specificScheme" placeholder="请输入具体方案"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="经度" prop="longitude">
              <el-input v-model="form.longitude" placeholder="请输入经度"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="纬度" prop="latitude">
              <el-input v-model="form.latitude" placeholder="请输入纬度"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="方案处理进展" prop="projectProcessingProgress">
              <el-input v-model="form.projectProcessingProgress" placeholder="请输入方案处理进展"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="方案是否落地" prop="planImplementation">
              <el-input v-model="form.planImplementation" placeholder="请输入方案是否落地"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="用户10分评价意愿" prop="userEvaluationIntention">
              <el-select v-model="form.userEvaluationIntention" placeholder="请选择用户10分评价意愿">
                <el-option v-for="dict in dict.type.user_rating"
                           :key="dict.value"
                           :label="dict.label"
                           :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否上传闭环录音" prop="uploadClosedLoopRecording">
              <el-input v-model="form.uploadClosedLoopRecording" placeholder="请输入是否上传闭环录音"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="投诉安抚责任人" prop="complaintsAppeaseThoseResponsible">
              <el-input v-model="form.complaintsAppeaseThoseResponsible" placeholder="请输入投诉安抚责任人"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="投诉处理组" prop="complaintsHandlingUnit">
              <el-select v-model="form.complaintsHandlingUnit" placeholder="请选择投诉处理组">
                <el-option v-for="dict in dict.type.complaints_handling_unit"
                           :key="dict.value"
                           :label="dict.label"
                           :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="投诉工单派发日期" prop="dateOfComplaint">
              <el-input v-model="form.dateOfComplaint" placeholder="请输入投诉工单派发日期"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="处理责任人更新反馈时间" prop="updateFeedbackTime">
              <el-input v-model="form.updateFeedbackTime" placeholder="请输入处理责任人更新反馈时间"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="用户闭环时间" prop="closedLoopTime">
              <el-input v-model="form.closedLoopTime" placeholder="请输入用户闭环时间"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="投诉处理备注" prop="complaintHandlingRemarks">
              <el-input v-model="form.complaintHandlingRemarks" placeholder="请输入投诉处理备注"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="投诉是否反馈更新" prop="complaintFeedbackUpdate">
              <el-input v-model="form.complaintFeedbackUpdate" placeholder="请输入投诉是否反馈更新"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="自投诉起时长" prop="timeSinceTheComplaint">
              <el-input v-model="form.timeSinceTheComplaint" placeholder="请输入自投诉起时长"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="是否超时工单标记" prop="overtimeWorkOrderFlag">
              <el-select v-model="form.overtimeWorkOrderFlag" placeholder="请选择是否超时工单标记">
                <el-option v-for="dict in dict.type.overtime_work_order_flag"
                           :key="dict.value"
                           :label="dict.label"
                           :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {addComplaint, delComplaint, getComplaint, listComplaint, updateComplaint} from "@/api/system/complaint";
import {getToken} from "@/utils/auth";

export default {
  dicts: ['type_of_complaint', 'complaint_district', 'problem_delimiting', 'problem_classification', 'complaint_network_system', 'overlay_scene', 'work_order_link', 'solution_category', 'solution_subclass', 'duration_name', 'user_rating', 'complaints_handling_unit', 'overtime_work_order_flag'],
  name: "Complaint",
  data() {
    return {
      uploadUrl: process.env.VUE_APP_BASE_API + "/system/complaint/importExcel", // 上传的图片服务器地址
      headers: {
        Authorization: "Bearer " + getToken()
      },
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 投诉问题表格数据
      complaintList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        complaintDate: null,
        acceptanceNumber: null,
        complaintUniqueIdentifier: null,
        numberOfRepeatedComplaints: null,
        workOrderSerialNumber: null,
        returningVisitor: null,
        typeOfComplaint: null,
        normalizedAddress: null,
        normalizedAddressStatistics: null,
        priority: null,
        complaintDistrict: null,
        complaintAddress: null,
        problemDescription: null,
        problemDelimiting: null,
        problemClassification: null,
        serviceClassification: null,
        complaintNetworkSystem: null,
        overlayScene: null,
        currentProgress: null,
        currentLink: null,
        solutionCategory: null,
        solutionSubclass: null,
        existenceDuration: null,
        existenceDurationName: null,
        specificScheme: null,
        longitude: null,
        latitude: null,
        projectProcessingProgress: null,
        planImplementation: null,
        userEvaluationIntention: null,
        uploadClosedLoopRecording: null,
        complaintsAppeaseThoseResponsible: null,
        complaintsHandlingUnit: null,
        dateOfComplaint: null,
        updateFeedbackTime: null,
        closedLoopTime: null,
        complaintHandlingRemarks: null,
        complaintFeedbackUpdate: null,
        timeSinceTheComplaint: null,
        overtimeWorkOrderFlag: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询投诉问题列表 */
    getList() {
      this.loading = true;
      listComplaint(this.queryParams).then(response => {
        this.complaintList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        complaintDate: null,
        acceptanceNumber: null,
        complaintUniqueIdentifier: null,
        numberOfRepeatedComplaints: null,
        workOrderSerialNumber: null,
        returningVisitor: null,
        typeOfComplaint: null,
        normalizedAddress: null,
        normalizedAddressStatistics: null,
        priority: null,
        complaintDistrict: null,
        complaintAddress: null,
        problemDescription: null,
        problemDelimiting: null,
        problemClassification: null,
        serviceClassification: null,
        complaintNetworkSystem: null,
        overlayScene: null,
        currentProgress: null,
        currentLink: null,
        solutionCategory: null,
        solutionSubclass: null,
        existenceDuration: null,
        existenceDurationName: null,
        specificScheme: null,
        longitude: null,
        latitude: null,
        projectProcessingProgress: null,
        planImplementation: null,
        userEvaluationIntention: null,
        uploadClosedLoopRecording: null,
        complaintsAppeaseThoseResponsible: null,
        complaintsHandlingUnit: null,
        dateOfComplaint: null,
        updateFeedbackTime: null,
        closedLoopTime: null,
        complaintHandlingRemarks: null,
        complaintFeedbackUpdate: null,
        timeSinceTheComplaint: null,
        overtimeWorkOrderFlag: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加投诉问题";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getComplaint(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改投诉问题";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateComplaint(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addComplaint(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除投诉问题编号为"' + ids + '"的数据项？').then(function () {
        return delComplaint(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    handleSuccess(response, file) {
      if (response.code === 200) {
        this.$message({
          dangerouslyUseHTMLString: true,
          message: "文件：《" + file.name + "》导入成功",
          type: file.status
        });
      }
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/complaint/export', {
        ...this.queryParams
      }, `投诉问题跟踪表-${this.formatLocalDate(new Date())}.xlsx`)
    },
    formatLocalDate(date) {
      return (
        date.getFullYear() + '-' +
        (date.getMonth() + 1).toString().padStart(2, '0') + '-' +
        date.getDate().toString().padStart(2, '0')
      );
    }
  }
};
</script>
